home *** CD-ROM | disk | FTP | other *** search
/ Network Support Library / RoseWare - Network Support Library.iso / apidev / spxcht.arc / MYALLOC.C < prev    next >
Text File  |  1987-12-22  |  927b  |  48 lines

  1. /*****************************************************************************
  2.  *
  3.  * Program Name:  CONNECT
  4.  *
  5.  * Filename:      myalloc.c
  6.  *
  7.  * Date Created:  December 1, 1987
  8.  *
  9.  * Programmers:      Bryan Sparks
  10.  *                  Software Consultant
  11.  *                    API Consulting
  12.  *                  Novell Inc.
  13.  *
  14.  * Files used:      connect.c
  15.  *
  16.  * Comments:
  17.  *    This is an alloc program taken mostly from Kernighan & Ritchie.
  18.  *
  19.  ****************************************************************************/
  20. #define        ALLOCSIZE    7000
  21.  
  22. char    allocbuf[ALLOCSIZE];
  23. char    *allocp = allocbuf;
  24.  
  25.  
  26. char *myalloc(n, size)
  27. int        n;
  28. int        size;
  29. {
  30.     int        numberOfBytes;
  31.  
  32.     numberOfBytes = n*size;
  33.     if ( allocp + numberOfBytes <= allocbuf + ALLOCSIZE ) {
  34.         allocp += numberOfBytes;
  35.         return ( allocp - numberOfBytes );
  36.     }
  37.     else
  38.         return (0);
  39. }
  40.  
  41. myfree(p)
  42. char    *p;
  43. {
  44.     if ( p >= allocbuf && p < allocbuf + ALLOCSIZE )
  45.         allocp = p;
  46. }
  47.  
  48.